package edu.thu.studio.ormdesigner.editor.dialog.tab.table;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.TabFolder;

import edu.thu.studio.ormdesigner.common.InputException;
import edu.thu.studio.ormdesigner.common.ValidatableTabWrapper;
import edu.thu.studio.ormdesigner.editor.dialog.NodeDialog;
import edu.thu.studio.ormdesigner.model.orm.table.Table;
import edu.thu.studio.ormdesigner.util.Properties;

public class ColumnTabWrapper extends ValidatableTabWrapper {
    
    private NodeDialog tableViewDialog;
    
    @SuppressWarnings("unused")
    private TableComposite tableComposite;
    
    private Table table;
    
    public ColumnTabWrapper(NodeDialog dialog, TabFolder parent, Table table) {
        super(dialog, parent, Properties.diagram_label_table_column);
        this.table = table;
    }
    
    @Override
    public void validatePage() throws InputException {
        
    }
    
    @Override
    protected void initComposite() {
        this.setLayout(new GridLayout());
        createBody(this);
    }
    
    @Override
    public void perfomeOK() {
        
    }
    
    @Override
    public void setInitFocus() {
        
    }
    
    private void createBody(Composite parent) {
        Group content = new Group(parent, SWT.NONE);
        GridData gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        content.setLayoutData(gridData);
        content.setLayout(new GridLayout(1, false));
        this.initTable(content);
    }
    
    private void initTable(Composite parent) {
        tableComposite = new TableComposite(parent, table, table.getColumns().getObjectList(),
            this.tableViewDialog, true, 1);
    }
    
}
